package com.toutou.base.bindhelper

import android.widget.ImageView
import androidx.databinding.BindingAdapter
import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy

class ImageBDAdapter {
    companion object {
        @JvmStatic
        @BindingAdapter("imgSrc")
        fun imageSrc(view: ImageView, imgSrc: Int) {
            view.setImageResource(imgSrc)
        }

        @JvmStatic
        @BindingAdapter(value = ["imgUrl"], requireAll = false)
        fun imageUrl(view: ImageView, imgUrl: String?) {
            Glide.with(view.context).load(imgUrl?:"")
                .diskCacheStrategy(DiskCacheStrategy.ALL)
                .into(view)
        }
    }
}